package com.wangys.controller;

import com.wangys.entities.Sfb;

import com.wangys.mapper.SfbMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@ResponseBody
@CrossOrigin
@RequestMapping("/sfb")
public class SfdController {
    @Autowired(required = false)
    private SfbMapper sfbMapper;

    @RequestMapping("/select")
    public List<Sfb> select(){
        List<Sfb> list = sfbMapper.select();
        return list;
    }
    @RequestMapping("/add")
    public void add(Sfb sfb){
        sfbMapper.add(sfb);
    }
    @RequestMapping("/delete")
    public void delete(int id){
        sfbMapper.delete(id);
    }
    @RequestMapping("/byId")
    public Sfb byId(int id){
        return sfbMapper.byId(id);
    }
    @RequestMapping("/update")
    public void update(Sfb sfb){
        sfbMapper.update(sfb);
    }
    @RequestMapping("/deleteAll")
    public void deleteAll(String ids){
        String[] split = ids.split(",");
        List<Integer> arrayList=new ArrayList<Integer>();
        for ( String iid:split) {
            arrayList.add(Integer.parseInt(iid));
        }
        sfbMapper.deleteAll(arrayList);
    }
    @RequestMapping("/getCount")
    public List<Sfb> getCount(){
        return sfbMapper.getCount();
    }
    @RequestMapping("/like")
    public List<Sfb> like(Sfb sfb){
        return sfbMapper.like(sfb);
    }
}
